typedef struct{
	double score;	
}ElemType;

typedef struct Node{
	ElemType data;
	Node *next;
}Node,*LinkNode;

bool InitScore(LinkNode &L){
     L=new Node;
     if(!L)
		 return true;
	 L->next=NULL;
	 return true;
}

int GetLength(LinkNode L){
	int len=0;
	LinkNode p=L;
	while(p->next){
		len++;
		p=p->next;
	}
	return len;

}
bool IsEmpty(LinkNode L){
	if(!L->next)
		return true;
	return false;
}

bool GetElem(LinkNode L, int i, ElemType& e){
	if(i<1||i>GetLength(L))
		return false;
	LinkNode p=L;
	
	for(int j=1;j<i;j++){
		p=p->next;
		
	}
	e=p->data;
	return true;
}



int Isequal(ElemType left,ElemType right){
	if(fabs(left.score-right.score)<1.e-5)
		return true;
	return false;
}
void TraverseListnew(LinkNode L,int n){
	LinkNode p = L;
	int i = 0;
	do{
		i++;
		if (i > n)
			break;
	cout << p->data.score << " ";
	}while (p = p->next);

	cout << endl;
}

void TraverseList(LinkNode L){
	LinkNode p = L;
	while (p->next)
	{
		cout << p->data.score << " ";
		p=p->next;

	}
	cout << endl;
}


void ShowList(LinkNode L,int n){
	LinkNode p=L;
	for(int i= 0; i<n; i++)
	{
		cout<<p->data.score<<"  ";
		p=p->next;
	}

	


int LocateElem(LinkNode L,ElemType e){
	LinkNode p=L;
	int i=0,k=0;
	while(p->next){
		i++;
		k++;
		if(Isequal(p->data,e)){
			return i;
			break;
		}
		else k=-1;
		p=p->next;
	}
	if(k==-1)
		return k;
}

LinkNode SearchElem(LinkNode L, ElemType e){
	LinkNode p=L;
	
	while(p->next){
		
		if(Isequal(p->data,e))
			break;
		p=p->next;
	}
	return p;

}

bool InsertElem(LinkNode& L, int i, ElemType e){
	if(i<1)
		return false;
	LinkNode p=L;
	int j=0;
	while((p->next)&&(j<i-1)){
		p=p->next;
		j++;
	}
	if(!p)
		return false;
	LinkNode s=new Node();
	s->data=e;
	s->next=p->next;
	p->next=s;
    return true;
}

bool DeleteElem(LinkNode& L, int i){
	if(i<1)
		return false;
	LinkNode p=L;
	int j=0;
	
	while((p->next)&&(j<i-1)){
		p=p->next;
		j++;
	}
	if(!p)
		return false;
	LinkNode q;
	q=p->next;
	p->next=q->next;
	delete q;
	return true;
}